package uit.shoeshop.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import com.opensymphony.xwork2.ActionSupport;

import uit.shoeshop.dto.ProductDTO;
import uit.shoeshop.model.FeaturedModel;

import java.util.ArrayList;

public class FeaturedAction extends ActionSupport implements ServletRequestAware,ServletResponseAware{
	private static final long serialVersionUID = 1L;
	private HttpServletRequest request;
	private HttpServletResponse response;

	private ArrayList<ProductDTO> featuredProduct;
	
	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	@Override
	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
	}
	
    public String execute() throws Exception {
    	FeaturedModel featured = new FeaturedModel();
    	try{
    		setFeaturedProduct(featured.getAllFeaturedProduct());
    	}catch(Exception e){
    		return ERROR;
    	}finally{
    		featured = null;
    	}
    	
        return SUCCESS;
    }

	public void setFeaturedProduct(ArrayList<ProductDTO> featuredProduct) {
		this.featuredProduct = featuredProduct;
	}

	public ArrayList<ProductDTO> getFeaturedProduct() {
		return featuredProduct;
	}
}
